package jjn.carl_round2;

import java.util.Scanner;

/**
 * @author Jiang Jining
 * @since 2023-09-17 23:24
 */
public class LeetCode27 {
    public int removeElement(int[] nums, int val) {
        int l = 0;
        for (int r = l; r < nums.length; r++) {
            if (nums[r] != val) {
                nums[l] = nums[r];
                l++;
            }
        }
        return l;
    }
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int val = scanner.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = scanner.nextInt();
        }
        int removedElement = new LeetCode27().removeElement(nums, val);
        System.out.println(removedElement);
    }
}
